package com.kdg.javaEight;

import java.lang.annotation.Repeatable;
import java.sql.Date;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import java.time.temporal.ChronoUnit;
import java.util.Locale;

/**
 * Created by kong on 2017/8/31.
 */
public class TestTimeAPI {
    public static void main(String[] args) {
        /**
         * Clock提供了对当前时间和日期的访问功能。
         */
        Clock clock = Clock.systemDefaultZone();
        System.out.println(clock.millis()+"--"+System.currentTimeMillis()+"--"+clock.getZone());

        Instant instant = clock.instant();
        java.util.Date from = Date.from(instant);

//        System.out.println(ZoneId.getAvailableZoneIds());  //所有时区
        ZoneId zone1 = ZoneId.of("Asia/Shanghai");
        ZoneId zone2 = ZoneId.of("Africa/Cairo");

        LocalTime now1 = LocalTime.now(zone1);
        LocalTime now2 = LocalTime.now(zone2);
        System.out.println(now1+"--"+now2+"---"+now1.isBefore(now2));

        LocalDate now = LocalDate.now();
        LocalDate tomorrow = now.plus(1, ChronoUnit.DAYS);
        LocalDate yesterday = tomorrow.minusDays(2);
        DayOfWeek dayOfWeek = now.getDayOfWeek();

        DateTimeFormatter dateTimeFormatter = DateTimeFormatter
                .ofLocalizedDate(FormatStyle.MEDIUM).withLocale(Locale.GERMAN);
        LocalDate parse = LocalDate.parse("25.12.2018", dateTimeFormatter);

        System.out.println(now+"-"+tomorrow+"-"+yesterday+"---"+dayOfWeek+"---"+parse);

    }
}

@interface Hints {
    Hint[] value();
}

@Repeatable(Hints.class)
@interface Hint {
    String value();
}

@Hint("hint1")
@Hint("hint2")   //可重复注解
class Person {}